// components/modal/index.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        item: Object,
        type: String,
        baseUrl: String
    },

    /**
     * 组件的初始数据
     */
    data: {
        check: true
    },

    /**
     * 组件的方法列表
     */
    methods: {
        check() {
            this.setData({
                check: !this.data.check
            })
        },
        handleCancle() {
            this.triggerEvent('handleCancle');
        },
        addToCar(e) {
            let goods = e.currentTarget.dataset.goods
            if (goods.startTime > 0) {
                wx.showToast({
                    title: '秒杀还未开始',
                    icon: 'error'
                })
            } else {
                goods.size = "默认"
                this.triggerEvent('addToCar', goods);
            }
        },
        pay(e) {
            let goods = e.currentTarget.dataset.goods
            if (goods.startTime > 0) {
                wx.showToast({
                    title: '秒杀还未开始',
                    icon: 'error'
                })
            } else {
                goods.size = "默认"
                this.triggerEvent('pay', goods);
            }
        }
    }
})
